﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PortableMediator.Test.TestModels
{
    public class TestSubscriber : TestSubscriberBase, ITestSubscriber
    {
        public int MessageSinkVoidCalledCount { get; set; }

        public void MessageSinkVoid(string param)
        {
            MessageSinkVoidCalledCount++;
            Console.WriteLine("MessageSinkVoid:{0}",param);
        }

        public int MessageSinkStringCalledCount { get; set; }

        public string MessageSinkString(string param)
        {
            MessageSinkStringCalledCount++;
            Console.WriteLine("MessageSinkString:{0}", param);
            return param;
        }

        public int MessageSinkAsyncTaskCalledCount { get; set; }

        public async Task MessageSinkAsyncTask(string param) 
        {
            await Task.Run(() =>
            {
                MessageSinkAsyncTaskCalledCount++;
                Console.WriteLine("MessageSinkAsyncTask:{0}", param);
            });
        }

        public int MessageSinkAsyncTaskOfStringCalledCount { get; set; }

        public async Task<string> MessageSinkAsyncTaskOfString(string param)
        {
            return await Task.Run(() =>
            {
                MessageSinkAsyncTaskOfStringCalledCount++;
                Console.WriteLine("MessageSinkAsyncTaskOfString: {0}", param);
                return param;
            });
        }

        public int MessageAttributeSinkCalledCount { get; set; }

        [MediatorMessageSink("test")]
        public async Task MessageAttributeSink(string param)
        {
            await Task.Run(() =>
            {
                MessageAttributeSinkCalledCount++;
                Console.WriteLine("MessageAttributeSinkCalledCount: {0}", param);
                return param;
            });
        }

        [MediatorMessageSink("testProp")]
        public string MessageSinkStringProperty { get; set; }
    }
}
